package com.vtc.session13;

import com.vtc.R;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.ListView;
import android.widget.Toast;

public class StudentListActivity extends Activity{

	private ListView lv;
	public StudentAdapter adapter;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.studentlist_activity);
		lv = (ListView) findViewById(R.id.studentlist);
		
		adapter = new StudentAdapter(this);
		lv.setAdapter(adapter);		
	}
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
	    MenuInflater inflat  = getMenuInflater();
	    inflat.inflate(R.menu.student_menu, menu);
		return super.onCreateOptionsMenu(menu);
	}
	@Override
	public boolean onMenuItemSelected(int featureId, MenuItem item) {
		switch(item.getItemId()){
		    case R.id.miStAdd:
//		    	Intent i = new Intent(this,StudentAddActivity.class);
//		    	startActivity(i);
		    	StudentAddDialog addForm = new StudentAddDialog();
		    	addForm.parentForm = this;
		    	addForm.show(getFragmentManager(),"");		    	
			    break;
		    case R.id.miStDel:	
//		    	final String[] options = {"Option 1","Option 2","Option 3"};
//		    	AlertDialog.Builder builder = new AlertDialog.Builder(this);
//		    	builder.setTitle("Select option").setItems(options, new DialogInterface.OnClickListener() {
//					
//					@Override
//					public void onClick(DialogInterface dialog, int which) {
//						Toast.makeText(StudentListActivity.this, options[which], Toast.LENGTH_LONG).show();
//					}
//				});
//		    	builder.create();
//		    	builder.show();
		    	Dialog1Activity dialog = new Dialog1Activity();
		    	dialog.show(getFragmentManager(),"");
		    	
		    	break;
		}
		return false;
	}
}
